﻿using System;
using System.Linq.Expressions;
using FT.Architecture.Utils.Reflection;

namespace FT.Architecture.Queries
{
    public class Fetch<T>
    {
        private Fetch(Expression<Func<T, object>> expression)
        {
            PropertyPath = expression;
            PropertyName = Reflection.GetCombinedProperty(expression);
        }

        public string PropertyName { get; private set; }

        public Expression<Func<T, object>> PropertyPath { get; private set; }

        internal static Fetch<T> Create(Expression<Func<T, object>> expression)
        {
            return new Fetch<T>(expression);
        }
    }
}
